CMAKE_MINIMUM_REQUIRED (VERSION 3.0)

PROJECT(MYPROGRAM)


SET(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/SHAREDLIB)

# 生成静态库
SET(CMAKE_STATIC_LIBRARY_PREFIX "")
SET(CMAKE_STATIC_LIBRARY_SUFFIX ".LIB")
FILE(GLOB STATIC_LIBRARY_FILES ${PROJECT_SOURCE_DIR}/LIBRARYFILE/SRC/*.cpp)
ADD_LIBRARY(MY_STATIC_LIB STATIC ${STATIC_LIBRARY_FILES})
TARGET_INCLUDE_DIRECTORIES(MY_STATIC_LIB PRIVATE ${PROJECT_SOURCE_DIR}/LIBRARYFILE/include)
SET_TARGET_PROPERTIES(MY_STATIC_LIB PROPERTIES
    OUTPUT_NAME "MYSTATIC_LIBRARY"
    ARCHIVE_OUTPUT_DIRECTORY "STATIC_LIBRARY_DIRECTORY"
)

# 生成动态库
SET(CMAKE_SHARED_LIBRARY_PREFIX "")
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".DLL")
SET(CMAKE_IMPORT_LIBRARY_PREFIX "")
SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".LIB")
FILE(GLOB SHARED_LIBRARY_FILES ${PROJECT_SOURCE_DIR}/LIBRARYFILE/SRC/*.cpp)
ADD_LIBRARY(MY_SHARED_LIB SHARED ${SHARED_LIBRARY_FILES})
TARGET_INCLUDE_DIRECTORIES(MY_SHARED_LIB PRIVATE ${PROJECT_SOURCE_DIR}/LIBRARYFILE/include)
SET_TARGET_PROPERTIES(MY_SHARED_LIB PROPERTIES
    OUTPUT_NAME "MYSHARED_LIBRARY"
    CMAKE_LIBRARY_OUTPUT_DIRECTORY "SHARED_LIBRARY_DIRECTORY"
    # 此处其实没必要设置动态库的生成目录,因为根本不会创建
)

# 生成程序
FILE(GLOB PROGRAM_SOURCES_FILES ${PROJECT_SOURCE_DIR}/SRC/*.cpp)
ADD_EXECUTABLE(PROGRAM_LINK_STATIC main.cpp ${PROGRAM_SOURCES_FILES})
TARGET_INCLUDE_DIRECTORIES(PROGRAM_LINK_STATIC PRIVATE ${PROJECT_SOURCE_DIR}/INCLUDE)
TARGET_LINK_LIBRARIES(PROGRAM_LINK_STATIC MY_STATIC_LIB)  # 如果不需要链接库就注释掉.此处现在是链接的 MY_STATIC_LIB 这个库
SET_TARGET_PROPERTIES(PROGRAM_LINK_STATIC PROPERTIES
    OUTPUT_NAME "PROGRAM_LINK_STATIC"    
    RUNTIME_OUTPUT_DIRECTORY "PROGRAMFILE"
)

ADD_EXECUTABLE(PROGRAM_LINK_SHARED main.cpp ${PROGRAM_SOURCES_FILES})
TARGET_INCLUDE_DIRECTORIES(PROGRAM_LINK_SHARED PRIVATE ${PROJECT_SOURCE_DIR}/INCLUDE)
TARGET_LINK_LIBRARIES(PROGRAM_LINK_SHARED MY_SHARED_LIB)  # 如果不需要链接库就注释掉.此处现在是链接的 MY_STATIC_LIB 这个库
SET_TARGET_PROPERTIES(PROGRAM_LINK_SHARED PROPERTIES
    OUTPUT_NAME "PROGRAM_LINK_SHARED"    
    RUNTIME_OUTPUT_DIRECTORY "PROGRAMFILE"
)



# INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
# # 头文件路径
# FILE(GLOB SOURCES "./src/*.cpp")
# # 源文件路径
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
# # 设置输出程序所在路径



# add_executable(MYPROGRAM ${SOURCES} main.cpp)
# # 生成程序


# # find_library(PYTHON312_D_LIBRARY python312_d PATHS ${PROJECT_SOURCE_DIR}/lib NO_DEFAULT_PATH)
# # if(NOT PYTHON312_D_LIBRARY)
# #     message(FATAL_ERROR "Python 3.12 library not found!")
# # endif()

# # 然后，我们将这个变量传递给 target_link_libraries 来链接库
# # target_link_libraries(OutProgram ${PYTHON312_D_LIBRARY})